home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Nothing but Tetris
/
Nothing but Tetris.iso
/
amiga
/
wbtris_1.3
/
source
/
statistic.c.pp
/
statistic.c
Wrap
C/C++ Source or Header
|
2000-01-01
|
3KB
|
108 lines
#include "WBTRIS.h"
#define beveloff 50
__chip UWORD tileData[] = {
0x0080,0x7F80,0x7F80,0x7F80,0x7F80,0x7F80,0x7F80,
0xFF00,0xFF00,0xFF00,0xFF00,0xFF00,0xFF00,0x8000,
};
struct Image tile = {
0, 0,
9, 7, 2,
tileData,
0x0003, 0x0000,
NULL
};
extern struct TextAttr topaz8;
int StatisticField[19][4] = {
{1,1,1,1},{0,0,0,0},{0,0,1,1},{0,1,1,0},{0,0,0,0},{0,1,1,0},{0,0,1,1},{0,0,0,0},
{0,0,1,0},{0,1,1,1},{0,0,0,0},{0,1,0,0},{0,1,1,1},{0,0,0,0},{0,0,0,1},{0,1,1,1},
{0,0,0,0},{0,1,1,0},{0,1,1,0}
};
void statistic(WORD WBTRIS_Window_Left, WORD WBTRIS_Window_Top, int ob1, int ob2, int ob3, int ob4, int ob5, int ob6, int ob7)
{
extern APTR VisualInfo;
struct Window *win;
extern struct Screen *myscreen;
int i;
float max=0.0;
float laenge;
float objects[7];
struct IntuiText Zeile;
char s[80];
float summe = 0;
objects[0] = ob2;
objects[1] = ob6;
objects[2] = ob7;
objects[3] = ob3;
objects[4] = ob4;
objects[5] = ob5;
objects[6] = ob1;
Zeile.FrontPen = 1;
Zeile.BackPen = 0;
Zeile.DrawMode = JAM2;
Zeile.LeftEdge = 0;
Zeile.TopEdge = 0;
Zeile.ITextFont = &topaz8;
Zeile.NextText = NULL;
s[0] = '\0';
if (win = OpenWindowTags(NULL,
WA_Left, WBTRIS_Window_Left,
WA_Top, WBTRIS_Window_Top+(myscreen->Font->ta_YSize)+3,
WA_Width, 337,
WA_Height, 185,
WA_CloseGadget, TRUE,
WA_Title, "<-- Click to close",
WA_DragBar, TRUE,
WA_Activate, TRUE,
WA_IDCMP, IDCMP_CLOSEWINDOW | WFLG_DRAGBAR
| IDCMP_REFRESHWINDOW | WFLG_WINDOWACTIVE,
TAG_END)) {
DrawWin(win,VisualInfo);
for (i=0;i<7;i++) {
if (objects[i] > max)
max = objects[i];
summe = summe + objects[i];
}
if (summe == 0)
summe = 0.00000001;
if (max == 0)
max = 1;
for (i=0;i<7;i++) {
laenge = 172*objects[i]/max;
SetAPen(win->RPort,3);
RectFill(win->RPort, 47+25, 30-6+(21*i), (short)(25+47+laenge), 30+(21*i)+5);
sprintf(s, "%5.1f%%", 100*objects[i]/summe);
Zeile.IText = s;
PrintIText(win->RPort, &Zeile, 255, 30-4+(21*i));
s[0] = '\0';
}
WaitPort(win->UserPort);
CloseWindow(win);
}
}
void DrawWin(struct Window *win,APTR VisualInfo)
{
int i,j;
for (i=0;i<4;i++)
for (j=0;j<19;j++)
if (StatisticField[j][i] == 1)
DrawImage(win->RPort,&tile,9*i+25,7*j+30);
for (i=0;i<7;i++)
DrawBevelBox(win->RPort, 45+25 , 30-7+(i*21) , 177, 14 ,GTBB_Recessed, TRUE, GT_VisualInfo, VisualInfo);
}